#!/bin/sh

. /usr/share/common

if [ -z "$1" ]; then
	echo "Usage: $0 <mmc port> [-r]" >&2
	exit 1
fi

endpoint="/sys/devices/platform/jzmmc_v1.2.$1/present"
if [ ! -f "$endpoint" ]; then
	echo_error "No endpoint $endpoint"
	exit 1
fi

# Do REMOVE if -r supplied, otherwise INSERT
if [ "$2" = "-r" ]; then
	action="REMOVE"
else
	action="INSERT"
fi
echo "$action" > "$endpoint"

exit 0
